
export const initState={
    // 初始化data
    // 新人专享
    news: [],
    // 万人团
    groupon: [],
    // 倒计时
    countdown:[],
    // 秒杀
    seckill:[],
    // 商品信息
    indexgoods:[],
    // 导航标识
    flag:1,
    // 优惠券
    cheap:[],
}

export const reducer=(state,action)=>{
    switch(action.type){
        // 新人专享
        case "changeNews":
            return {
                ...state,
                news:action.news
            }
        // 万人团
        case "changeGroupon":
            return {
                ...state,
                groupon:action.groupon
            }
        // 倒计时
        case "changeCountdown":
            return {
                ...state,
                countdown:action.countdown
            }
        // 秒杀
        case "changeSeckill":
            return {
                ...state,
                seckill:action.seckill
            }
        // 商品信息
        case "changeIndexgoods":
            return {
                ...state,
                indexgoods:action.indexgoods
            }
        // 导航标识
        case "changeFlag":
            return {
                ...state,
                flag:action.flag
            }
        // 优惠券
        case "changeCheap":
            return {
                ...state,
                cheap:action.cheap
            }
        default:
            return state;
    }
}

export const actions={
    // 修改user的action
    // 新人专享
    changeNews:(news)=>({type:"changeNews",news}),
    // 万人团
    changeGroupon:(groupon)=>({type:"changeGroupon",groupon}),
    // 倒计时
    changeCountdown:(countdown)=>({type:"changeCountdown",countdown}),
    // 秒杀
    changeSeckill:(seckill)=>({type:"changeSeckill",seckill}),
    // 商品信息
    changeIndexgoods:(indexgoods)=>({type:"changeIndexgoods",indexgoods}),
    // 导航标识
    changeFlag:(flag)=>({type:"changeFlag",flag}),
    // 优惠券
    changeCheap:(cheap)=>({type:"changeCheap",cheap}),
}